package ua.at.javac.entity;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table (name="site")
public class Site implements Serializable{

	private static final long serialVersionUID = 1L;

	Site() {
	}

	@Id
	@ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
    @JoinColumn(name = "site_id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	Journal id;
	
	@Column(name="city")
	int city;
	
	@Column(name="http")
	String http;
	
	@Column(name="site_name")
	String site;
	

	public Journal getId() {
		return id;
	}

	public void setId(Journal id) {
		this.id = id;
	}

	public int getCity() {
		return city;
	}

	public void setCity(int city) {
		this.city = city;
	}

	public String getHttp() {
		return http;
	}

	public void setHttp(String http) {
		this.http = http;
	}

	public String getSite() {
		return site;
	}

	public void setSite(String site) {
		this.site = site;
	}

	@Override
	public String toString() {
		return "Site [id=" + id + ", city=" + city + ", http=" + http
				+ ", site=" + site + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + city;
		result = prime * result + ((http == null) ? 0 : http.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((site == null) ? 0 : site.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Site other = (Site) obj;
		if (city != other.city)
			return false;
		if (http == null) {
			if (other.http != null)
				return false;
		} else if (!http.equals(other.http))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (site == null) {
			if (other.site != null)
				return false;
		} else if (!site.equals(other.site))
			return false;
		return true;
	}

}
